﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Catering.Catering_Page.richang
{
    public partial class ContractorAptitude : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                this.LoadRep();
            }
        }

        /// <summary>
        /// 加载Rep
        /// </summary>
        /// <param name="classid"></param>
        /// <param name="classname"></param>
        public void LoadRep()
        {
            try
            {

            }
            catch
            {

            }
        }

        //添加
        [WebMethod]
        public static string Add(string _contractorName, string classId, string _evaluate, string _address, string _linker, string _linkphone, string _operationtype, string _state)
        {
            Catering_Model.ContractorAptitude _contractorAptitude = new Catering_Model.ContractorAptitude();
            _contractorAptitude.Address = _address;
            _contractorAptitude.ContractorName = _contractorName;
            _contractorAptitude.ClassId = Convert.ToInt32(classId);
            _contractorAptitude.Evaluate = _evaluate;
            _contractorAptitude.Linker = _linker;
            _contractorAptitude.LinkPhone = _linkphone;
            _contractorAptitude.OperationType = _operationtype;
            _contractorAptitude.State = _state;
            new Catering_Rules.ContractorAptitude().Add(_contractorAptitude);
            return "OK";
        }

        //修改
        [WebMethod]
        public static string Edit(string _id, string _contractorName, string classId, string _evaluate, string _address, string _linker, string _linkphone, string _operationtype, string _state)
        {
            int id = 0;
            int areaid = 0;
            Int32.TryParse(_id, out id);
            if (id <= 0) return "NO";

            Catering_Model.ContractorAptitude _contractorAptitude = new Catering_Model.ContractorAptitude();
            _contractorAptitude.Address = _address;
            _contractorAptitude.ContractorName = _contractorName;
            _contractorAptitude.ClassId = Convert.ToInt32(classId);
            _contractorAptitude.Evaluate = _evaluate;
            _contractorAptitude.Linker = _linker;
            _contractorAptitude.LinkPhone = _linkphone;
            _contractorAptitude.OperationType = _operationtype;
            _contractorAptitude.State = _state;
            new Catering_Rules.ContractorAptitude().Update(_contractorAptitude);

            return "OK";
        }

        [WebMethod]
        public static ArrayList Get(string _id)
        {
            ArrayList al = new ArrayList();
            Catering_Model.ContractorAptitude _contractorAptitude = new Catering_Rules.ContractorAptitude().GetModel(Convert.ToInt32(_id));
            al.Add(_contractorAptitude.Id);
            al.Add(_contractorAptitude.Address);
            al.Add(_contractorAptitude.ContractorName);
            al.Add(_contractorAptitude.ClassId);
            al.Add(_contractorAptitude.Evaluate);
            al.Add(_contractorAptitude.Linker);
            al.Add(_contractorAptitude.LinkPhone);
            al.Add(_contractorAptitude.OperationType);
            al.Add(_contractorAptitude.State);
            return al;
        }
        protected void Rept_aptitude_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "del")
            {
                int delID = Convert.ToInt32(e.CommandArgument);
                if (new Catering_Rules.ContractorAptitude().Delete(delID))
                {
                    
                }
            }
        }
    }
}